<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport"
	content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
<link rel="stylesheet" href="./css/font.css">
<link rel="stylesheet" href="./css/xadmin.css">
<script type="text/javascript" src="./js/jquery.min.js"></script>
<script type="text/javascript" src="./lib/layui/layui.js"
	charset="utf-8"></script>
<script type="text/javascript" src="./js/xadmin.js"></script>
<!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
<!--[if lt IE 9]>
      <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
      <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>

<body>
	<div class="x-body">
	<a class="layui-btn" id="addlink" ><i class="layui-icon">&#xe608;</i>添加联系人</a>
   		<table class="layui-table">
   			<thead>
				<tr><th>序号</th><th>联系人</th><th>性别</th><th>职位</th><th>手机</th><th>电话</th><th>邮箱</th><th>部门</th><th colspan="2">操作</th></tr>
			</thead>
			<tbody id="links">
			</tbody>
		</table>
	</div>
	<script>
	layui.use([ 'form', 'layer' ], function() {
		$ = layui.jquery;
		var form = layui.form, layer = layui.layer;
		$('#addlink').attr('onclick','x_admin_show(\'添加\',\'links-add.html#uuid='+window.location.hash.slice(8)+'\')');
		//填充数据
		$.ajax({
			url:'link_find',
			data:{'uuid':window.location.hash.slice(8)},
			success:function(result){
				var obj=JSON.parse(result);
				obj.forEach(function(value,index,array){
					$('#links').append('<tr><td>'+(index+1)+'</td><td>'+value.schlink_name+
							'</td><td>'+(value.schlink_sex==1?'男':'女')+'</td><td>'+value.schlink_position+
							'</td><td>'+value.schlink_phone+'</td><td>'+value.schlink_tel+
							'</td><td>'+value.schlink_email+'</td><td>'+value.schlink_dept+
							'</td><td><span class="layui-btn layui-btn-mini" onclick="x_admin_show(\'修改\',\'links-edit.html#uuid='+value.schlink_id+'\')">编辑</span>'+
							'</td><td><span class="layui-btn layui-btn-mini" onclick="link_del(this,\''+value.schlink_id+'\')">删除</span></td></tr>');
				});
			},
			error:function(error){alert(error)}
		});
	});
	function link_del(obj,uuid){
		$.get('link_del?uuid='+uuid,function(result,status){
			if(result==1){
				$(obj).parent().parent().remove();
				layui.layer.alert("操作成功", {icon : 6});
			}else{
				layui.layer.alert("操作失败", {icon : 6});
			}
		});
	}
	</script>
</body>

</html>